//do...while

#include<stdio.h>
#include<string.h>
#include<windows.h>
/*
//多个字符从两端移动向中间汇聚
int main()
{
    char arr1[] = "hello,,World!!!";
    char arr2[] = "##############";
    int left = 0;
    int right =strlen(arr1)-1;

    while (left<=right)
    {
        arr2[left] =arr1[left];
        arr2[right] =arr1[right];
        printf("%s\n",arr2);
        Sleep(500);//睡眠500ms,要引用头文件<windows.h>//S是大写
        system("cls");//清空屏幕

        left++;
        right--;
    }
    return 0;
}
*/

int main()
{
    int i;
    //假设正确密码为字符串"123456"
    char password[20]={0};
    //char trueword[]="123456";

    for (i=0;i<3;i++)
    {
        printf("请输入你的密码:>");
        scanf("%s",password);
        //if(password==trueword) - 两字符串比较不用==,用strcmp//要引用头文件<string.h>

        if (strcmp(password,"123456") ==0)//不懂为啥i在这里是随机值,..password要有取值大小
        {
            printf("恭喜你,登陆成功!\n");
            break;
        }
        else
        {
            printf("密码错误\n");
        }

    }
    if (i >=3 )
    {
        printf("3次密码都错误,退出登陆");

    }
    return 0;
}